using System;
using Microsoft.SPOT;
using MFToolkit.Net.Web;
using System.Threading;
using System.Text;
using System.Net;
using Microsoft.SPOT.Net.NetworkInformation;
using MFToolkit.Net.Ntp;
using System.IO;
using System.Reflection;
using System.Globalization;
using MFToolkit.MicroUtilities;
using Microsoft.SPOT.Net.Security;
using MFToolkit.Net.XBee;

namespace MicroHTTPConsole
{
    public class Program
    {
        internal static bool stopThread = false;

        #region certificate

        // Self Signed Certificate (Public and Private Key Concatenated).  Binary version of Certificates\SelfSigned.PEM
        public static byte[] caCert = new byte[] {
           0x2d,0x2d,0x2d,0x2d,0x2d,0x42,0x45,0x47,0x49,0x4e,0x20,0x43,0x45,0x52,0x54,
           0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x4d,0x49,
           0x49,0x45,0x70,0x7a,0x43,0x43,0x41,0x34,0x2b,0x67,0x41,0x77,0x49,0x42,0x41,
           0x67,0x49,0x4a,0x41,0x4d,0x55,0x2f,0x67,0x42,0x38,0x79,0x4a,0x6f,0x2b,0x79,
           0x4d,0x41,0x30,0x47,0x43,0x53,0x71,0x47,0x53,0x49,0x62,0x33,0x44,0x51,0x45,
           0x42,0x42,0x51,0x55,0x41,0x4d,0x49,0x47,0x54,0x4d,0x51,0x73,0x77,0x43,0x51,
           0x59,0x44,0x0a,0x56,0x51,0x51,0x47,0x45,0x77,0x4a,0x31,0x63,0x7a,0x45,0x4c,
           0x4d,0x41,0x6b,0x47,0x41,0x31,0x55,0x45,0x43,0x42,0x4d,0x43,0x64,0x32,0x45,
           0x78,0x45,0x44,0x41,0x4f,0x42,0x67,0x4e,0x56,0x42,0x41,0x63,0x54,0x42,0x31,
           0x4a,0x6c,0x5a,0x47,0x31,0x76,0x62,0x6d,0x51,0x78,0x45,0x6a,0x41,0x51,0x42,
           0x67,0x4e,0x56,0x42,0x41,0x6f,0x54,0x0a,0x43,0x55,0x31,0x70,0x59,0x33,0x4a,
           0x76,0x63,0x32,0x39,0x6d,0x64,0x44,0x45,0x4e,0x4d,0x41,0x73,0x47,0x41,0x31,
           0x55,0x45,0x43,0x78,0x4d,0x45,0x55,0x31,0x42,0x50,0x56,0x44,0x45,0x64,0x4d,
           0x42,0x73,0x47,0x41,0x31,0x55,0x45,0x41,0x78,0x4d,0x55,0x52,0x47,0x56,0x32,
           0x61,0x57,0x4e,0x6c,0x4c,0x6b,0x31,0x70,0x59,0x33,0x4a,0x76,0x0a,0x63,0x32,
           0x39,0x6d,0x64,0x43,0x35,0x44,0x62,0x32,0x30,0x78,0x49,0x7a,0x41,0x68,0x42,
           0x67,0x6b,0x71,0x68,0x6b,0x69,0x47,0x39,0x77,0x30,0x42,0x43,0x51,0x45,0x57,
           0x46,0x47,0x46,0x73,0x5a,0x47,0x56,0x75,0x62,0x45,0x42,0x74,0x61,0x57,0x4e,
           0x79,0x62,0x33,0x4e,0x76,0x5a,0x6e,0x51,0x75,0x59,0x32,0x39,0x74,0x4d,0x42,
           0x34,0x58,0x0a,0x44,0x54,0x41,0x34,0x4d,0x44,0x4d,0x79,0x4d,0x54,0x49,0x78,
           0x4d,0x7a,0x51,0x77,0x4e,0x31,0x6f,0x58,0x44,0x54,0x45,0x78,0x4d,0x44,0x4d,
           0x79,0x4d,0x54,0x49,0x78,0x4d,0x7a,0x51,0x77,0x4e,0x31,0x6f,0x77,0x67,0x5a,
           0x4d,0x78,0x43,0x7a,0x41,0x4a,0x42,0x67,0x4e,0x56,0x42,0x41,0x59,0x54,0x41,
           0x6e,0x56,0x7a,0x4d,0x51,0x73,0x77,0x0a,0x43,0x51,0x59,0x44,0x56,0x51,0x51,
           0x49,0x45,0x77,0x4a,0x33,0x59,0x54,0x45,0x51,0x4d,0x41,0x34,0x47,0x41,0x31,
           0x55,0x45,0x42,0x78,0x4d,0x48,0x55,0x6d,0x56,0x6b,0x62,0x57,0x39,0x75,0x5a,
           0x44,0x45,0x53,0x4d,0x42,0x41,0x47,0x41,0x31,0x55,0x45,0x43,0x68,0x4d,0x4a,
           0x54,0x57,0x6c,0x6a,0x63,0x6d,0x39,0x7a,0x62,0x32,0x5a,0x30,0x0a,0x4d,0x51,
           0x30,0x77,0x43,0x77,0x59,0x44,0x56,0x51,0x51,0x4c,0x45,0x77,0x52,0x54,0x55,
           0x45,0x39,0x55,0x4d,0x52,0x30,0x77,0x47,0x77,0x59,0x44,0x56,0x51,0x51,0x44,
           0x45,0x78,0x52,0x45,0x5a,0x58,0x5a,0x70,0x59,0x32,0x55,0x75,0x54,0x57,0x6c,
           0x6a,0x63,0x6d,0x39,0x7a,0x62,0x32,0x5a,0x30,0x4c,0x6b,0x4e,0x76,0x62,0x54,
           0x45,0x6a,0x0a,0x4d,0x43,0x45,0x47,0x43,0x53,0x71,0x47,0x53,0x49,0x62,0x33,
           0x44,0x51,0x45,0x4a,0x41,0x52,0x59,0x55,0x59,0x57,0x78,0x6b,0x5a,0x57,0x35,
           0x73,0x51,0x47,0x31,0x70,0x59,0x33,0x4a,0x76,0x63,0x32,0x39,0x6d,0x64,0x43,
           0x35,0x6a,0x62,0x32,0x30,0x77,0x67,0x67,0x45,0x69,0x4d,0x41,0x30,0x47,0x43,
           0x53,0x71,0x47,0x53,0x49,0x62,0x33,0x0a,0x44,0x51,0x45,0x42,0x41,0x51,0x55,
           0x41,0x41,0x34,0x49,0x42,0x44,0x77,0x41,0x77,0x67,0x67,0x45,0x4b,0x41,0x6f,
           0x49,0x42,0x41,0x51,0x44,0x48,0x79,0x63,0x58,0x33,0x58,0x66,0x64,0x70,0x54,
           0x4b,0x4d,0x44,0x66,0x58,0x61,0x31,0x6f,0x68,0x42,0x73,0x72,0x6e,0x4d,0x77,
           0x70,0x6e,0x5a,0x5a,0x78,0x48,0x61,0x58,0x76,0x45,0x51,0x6e,0x0a,0x46,0x47,
           0x32,0x31,0x78,0x41,0x74,0x4d,0x4e,0x67,0x47,0x4a,0x4b,0x4a,0x67,0x56,0x69,
           0x59,0x36,0x59,0x55,0x6a,0x63,0x5a,0x31,0x2b,0x47,0x66,0x6f,0x34,0x35,0x47,
           0x6e,0x6e,0x34,0x67,0x50,0x75,0x53,0x75,0x6b,0x48,0x79,0x36,0x76,0x65,0x65,
           0x53,0x43,0x53,0x52,0x75,0x7a,0x35,0x70,0x38,0x54,0x36,0x55,0x7a,0x57,0x6e,
           0x61,0x69,0x0a,0x33,0x39,0x63,0x42,0x42,0x59,0x31,0x34,0x44,0x68,0x2f,0x6e,
           0x45,0x56,0x6e,0x46,0x67,0x62,0x53,0x6d,0x56,0x6e,0x77,0x30,0x33,0x6f,0x58,
           0x79,0x6a,0x54,0x76,0x2f,0x4a,0x73,0x38,0x6d,0x69,0x47,0x47,0x2b,0x59,0x51,
           0x78,0x32,0x2b,0x34,0x41,0x46,0x51,0x63,0x48,0x38,0x31,0x79,0x5a,0x77,0x63,
           0x4a,0x2f,0x6d,0x76,0x48,0x2f,0x67,0x0a,0x66,0x57,0x78,0x47,0x6f,0x71,0x61,
           0x6b,0x74,0x43,0x6a,0x65,0x64,0x54,0x69,0x7a,0x64,0x31,0x7a,0x66,0x51,0x59,
           0x6b,0x73,0x4d,0x41,0x69,0x4d,0x6c,0x36,0x78,0x6e,0x64,0x6c,0x6c,0x71,0x36,
           0x69,0x56,0x32,0x55,0x49,0x6c,0x39,0x75,0x50,0x59,0x61,0x58,0x75,0x73,0x30,
           0x31,0x35,0x65,0x56,0x6b,0x71,0x64,0x63,0x55,0x76,0x45,0x31,0x0a,0x43,0x75,
           0x56,0x35,0x43,0x38,0x51,0x57,0x41,0x77,0x72,0x42,0x34,0x68,0x64,0x48,0x51,
           0x43,0x75,0x64,0x77,0x4b,0x36,0x61,0x76,0x4e,0x36,0x58,0x39,0x49,0x48,0x6a,
           0x6f,0x33,0x4f,0x7a,0x76,0x30,0x45,0x33,0x32,0x49,0x53,0x69,0x2b,0x77,0x53,
           0x4d,0x53,0x4f,0x52,0x50,0x6e,0x74,0x33,0x41,0x66,0x38,0x30,0x47,0x70,0x68,
           0x4b,0x4f,0x0a,0x6b,0x53,0x4d,0x68,0x44,0x58,0x45,0x75,0x6f,0x49,0x63,0x6f,
           0x4b,0x38,0x59,0x45,0x71,0x67,0x38,0x58,0x33,0x6c,0x67,0x4c,0x67,0x69,0x6b,
           0x2f,0x6d,0x66,0x48,0x67,0x57,0x74,0x66,0x63,0x69,0x56,0x2b,0x37,0x38,0x61,
           0x52,0x36,0x6e,0x39,0x6d,0x6e,0x41,0x67,0x4d,0x42,0x41,0x41,0x47,0x6a,0x67,
           0x66,0x73,0x77,0x67,0x66,0x67,0x77,0x0a,0x48,0x51,0x59,0x44,0x56,0x52,0x30,
           0x4f,0x42,0x42,0x59,0x45,0x46,0x4e,0x6e,0x64,0x6d,0x35,0x52,0x72,0x69,0x6a,
           0x79,0x75,0x4b,0x6c,0x47,0x32,0x50,0x58,0x35,0x4f,0x66,0x4a,0x75,0x54,0x5a,
           0x44,0x44,0x6a,0x4d,0x49,0x48,0x49,0x42,0x67,0x4e,0x56,0x48,0x53,0x4d,0x45,
           0x67,0x63,0x41,0x77,0x67,0x62,0x32,0x41,0x46,0x4e,0x6e,0x64,0x0a,0x6d,0x35,
           0x52,0x72,0x69,0x6a,0x79,0x75,0x4b,0x6c,0x47,0x32,0x50,0x58,0x35,0x4f,0x66,
           0x4a,0x75,0x54,0x5a,0x44,0x44,0x6a,0x6f,0x59,0x47,0x5a,0x70,0x49,0x47,0x57,
           0x4d,0x49,0x47,0x54,0x4d,0x51,0x73,0x77,0x43,0x51,0x59,0x44,0x56,0x51,0x51,
           0x47,0x45,0x77,0x4a,0x31,0x63,0x7a,0x45,0x4c,0x4d,0x41,0x6b,0x47,0x41,0x31,
           0x55,0x45,0x0a,0x43,0x42,0x4d,0x43,0x64,0x32,0x45,0x78,0x45,0x44,0x41,0x4f,
           0x42,0x67,0x4e,0x56,0x42,0x41,0x63,0x54,0x42,0x31,0x4a,0x6c,0x5a,0x47,0x31,
           0x76,0x62,0x6d,0x51,0x78,0x45,0x6a,0x41,0x51,0x42,0x67,0x4e,0x56,0x42,0x41,
           0x6f,0x54,0x43,0x55,0x31,0x70,0x59,0x33,0x4a,0x76,0x63,0x32,0x39,0x6d,0x64,
           0x44,0x45,0x4e,0x4d,0x41,0x73,0x47,0x0a,0x41,0x31,0x55,0x45,0x43,0x78,0x4d,
           0x45,0x55,0x31,0x42,0x50,0x56,0x44,0x45,0x64,0x4d,0x42,0x73,0x47,0x41,0x31,
           0x55,0x45,0x41,0x78,0x4d,0x55,0x52,0x47,0x56,0x32,0x61,0x57,0x4e,0x6c,0x4c,
           0x6b,0x31,0x70,0x59,0x33,0x4a,0x76,0x63,0x32,0x39,0x6d,0x64,0x43,0x35,0x44,
           0x62,0x32,0x30,0x78,0x49,0x7a,0x41,0x68,0x42,0x67,0x6b,0x71,0x0a,0x68,0x6b,
           0x69,0x47,0x39,0x77,0x30,0x42,0x43,0x51,0x45,0x57,0x46,0x47,0x46,0x73,0x5a,
           0x47,0x56,0x75,0x62,0x45,0x42,0x74,0x61,0x57,0x4e,0x79,0x62,0x33,0x4e,0x76,
           0x5a,0x6e,0x51,0x75,0x59,0x32,0x39,0x74,0x67,0x67,0x6b,0x41,0x78,0x54,0x2b,
           0x41,0x48,0x7a,0x49,0x6d,0x6a,0x37,0x49,0x77,0x44,0x41,0x59,0x44,0x56,0x52,
           0x30,0x54,0x0a,0x42,0x41,0x55,0x77,0x41,0x77,0x45,0x42,0x2f,0x7a,0x41,0x4e,
           0x42,0x67,0x6b,0x71,0x68,0x6b,0x69,0x47,0x39,0x77,0x30,0x42,0x41,0x51,0x55,
           0x46,0x41,0x41,0x4f,0x43,0x41,0x51,0x45,0x41,0x61,0x66,0x69,0x61,0x39,0x69,
           0x79,0x30,0x68,0x62,0x33,0x75,0x73,0x34,0x45,0x36,0x59,0x47,0x2b,0x53,0x52,
           0x57,0x49,0x50,0x50,0x6f,0x73,0x44,0x0a,0x78,0x4b,0x6f,0x67,0x6e,0x46,0x39,
           0x4b,0x6c,0x74,0x6a,0x77,0x44,0x4d,0x7a,0x37,0x5a,0x48,0x4e,0x67,0x5a,0x56,
           0x6a,0x6d,0x50,0x5a,0x32,0x2f,0x79,0x42,0x64,0x4a,0x50,0x69,0x72,0x6f,0x6f,
           0x4d,0x4e,0x39,0x59,0x6e,0x59,0x6f,0x41,0x35,0x61,0x33,0x70,0x68,0x71,0x71,
           0x46,0x79,0x33,0x42,0x55,0x6c,0x36,0x2f,0x75,0x33,0x63,0x77,0x0a,0x39,0x2b,
           0x73,0x46,0x54,0x48,0x34,0x75,0x67,0x4b,0x61,0x34,0x4a,0x38,0x76,0x6b,0x63,
           0x58,0x77,0x72,0x63,0x48,0x41,0x4c,0x71,0x6b,0x67,0x75,0x41,0x6c,0x65,0x61,
           0x77,0x69,0x41,0x64,0x2f,0x37,0x4e,0x4d,0x31,0x54,0x4f,0x54,0x35,0x2b,0x34,
           0x54,0x49,0x79,0x4d,0x4b,0x4f,0x70,0x6f,0x4a,0x55,0x34,0x57,0x5a,0x30,0x66,
           0x6d,0x48,0x0a,0x44,0x61,0x6e,0x4d,0x74,0x4c,0x38,0x30,0x34,0x59,0x49,0x4e,
           0x5a,0x52,0x30,0x52,0x75,0x2b,0x41,0x37,0x55,0x75,0x62,0x78,0x54,0x7a,0x4c,
           0x59,0x50,0x4a,0x35,0x52,0x52,0x68,0x31,0x32,0x6a,0x67,0x2b,0x73,0x65,0x46,
           0x47,0x68,0x77,0x58,0x30,0x73,0x6e,0x2f,0x75,0x42,0x36,0x70,0x42,0x71,0x71,
           0x75,0x4e,0x52,0x62,0x4d,0x35,0x78,0x0a,0x48,0x46,0x78,0x37,0x4c,0x37,0x46,
           0x2f,0x6d,0x67,0x5a,0x54,0x41,0x37,0x6b,0x78,0x7a,0x45,0x37,0x64,0x6e,0x44,
           0x4a,0x43,0x79,0x62,0x5a,0x77,0x7a,0x4c,0x6b,0x6e,0x66,0x71,0x62,0x73,0x68,
           0x6a,0x77,0x61,0x44,0x6d,0x50,0x30,0x6e,0x59,0x57,0x32,0x57,0x43,0x48,0x6d,
           0x32,0x58,0x75,0x73,0x59,0x32,0x66,0x36,0x52,0x6d,0x45,0x70,0x0a,0x6f,0x2f,
           0x66,0x4a,0x66,0x2b,0x67,0x36,0x6b,0x5a,0x2b,0x35,0x6d,0x55,0x53,0x4a,0x4d,
           0x41,0x4b,0x65,0x61,0x59,0x47,0x68,0x33,0x36,0x4c,0x6a,0x76,0x37,0x68,0x35,
           0x66,0x4d,0x74,0x5a,0x42,0x66,0x46,0x66,0x67,0x78,0x61,0x73,0x38,0x47,0x53,
           0x34,0x37,0x6b,0x64,0x53,0x61,0x65,0x51,0x39,0x6c,0x77,0x3d,0x3d,0x0a,0x2d,
           0x2d,0x2d,0x2d,0x2d,0x45,0x4e,0x44,0x20,0x43,0x45,0x52,0x54,0x49,0x46,0x49,
           0x43,0x41,0x54,0x45,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a
       };

        public static byte[] newCert = new byte[]{
           0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x3a,0x0a,0x20,0x20,
           0x20,0x20,0x44,0x61,0x74,0x61,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x56,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3a,0x20,0x33,0x20,0x28,0x30,0x78,
           0x32,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x53,0x65,0x72,0x69,
           0x61,0x6c,0x20,0x4e,0x75,0x6d,0x62,0x65,0x72,0x3a,0x20,0x32,0x38,0x36,0x20,
           0x28,0x30,0x78,0x31,0x31,0x65,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x53,0x69,0x67,0x6e,0x61,0x74,0x75,0x72,0x65,0x20,0x41,0x6c,0x67,0x6f,
           0x72,0x69,0x74,0x68,0x6d,0x3a,0x20,0x73,0x68,0x61,0x31,0x57,0x69,0x74,0x68,
           0x52,0x53,0x41,0x45,0x6e,0x63,0x72,0x79,0x70,0x74,0x69,0x6f,0x6e,0x0a,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x49,0x73,0x73,0x75,0x65,0x72,0x3a,0x20,
           0x43,0x3d,0x75,0x73,0x2c,0x20,0x53,0x54,0x3d,0x77,0x61,0x2c,0x20,0x4c,0x3d,
           0x52,0x65,0x64,0x6d,0x6f,0x6e,0x64,0x2c,0x20,0x4f,0x3d,0x4d,0x69,0x63,0x72,
           0x6f,0x73,0x6f,0x66,0x74,0x2c,0x20,0x4f,0x55,0x3d,0x53,0x50,0x4f,0x54,0x2c,
           0x20,0x43,0x4e,0x3d,0x44,0x65,0x76,0x69,0x63,0x65,0x2e,0x4d,0x69,0x63,0x72,
           0x6f,0x73,0x6f,0x66,0x74,0x2e,0x43,0x6f,0x6d,0x2f,0x65,0x6d,0x61,0x69,0x6c,
           0x41,0x64,0x64,0x72,0x65,0x73,0x73,0x3d,0x61,0x6c,0x64,0x65,0x6e,0x6c,0x40,
           0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x2e,0x63,0x6f,0x6d,0x0a,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x56,0x61,0x6c,0x69,0x64,0x69,0x74,0x79,
           0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x4e,0x6f,
           0x74,0x20,0x42,0x65,0x66,0x6f,0x72,0x65,0x3a,0x20,0x4d,0x61,0x72,0x20,0x32,
           0x31,0x20,0x32,0x32,0x3a,0x33,0x32,0x3a,0x30,0x38,0x20,0x32,0x30,0x30,0x38,
           0x20,0x47,0x4d,0x54,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x4e,0x6f,0x74,0x20,0x41,0x66,0x74,0x65,0x72,0x20,0x3a,0x20,0x4d,
           0x61,0x72,0x20,0x32,0x31,0x20,0x32,0x32,0x3a,0x33,0x32,0x3a,0x30,0x38,0x20,
           0x32,0x30,0x30,0x39,0x20,0x47,0x4d,0x54,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x53,0x75,0x62,0x6a,0x65,0x63,0x74,0x3a,0x20,0x43,0x3d,0x75,0x73,
           0x2c,0x20,0x53,0x54,0x3d,0x77,0x61,0x2c,0x20,0x4c,0x3d,0x72,0x65,0x64,0x6d,
           0x6f,0x6e,0x64,0x2c,0x20,0x4f,0x3d,0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,
           0x74,0x2c,0x20,0x4f,0x55,0x3d,0x53,0x50,0x4f,0x54,0x2c,0x20,0x43,0x4e,0x3d,
           0x44,0x65,0x76,0x69,0x63,0x65,0x2e,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,
           0x74,0x2e,0x43,0x6f,0x6d,0x2f,0x65,0x6d,0x61,0x69,0x6c,0x41,0x64,0x64,0x72,
           0x65,0x73,0x73,0x3d,0x61,0x6c,0x64,0x65,0x6e,0x6c,0x40,0x6d,0x69,0x63,0x72,
           0x6f,0x73,0x6f,0x66,0x74,0x2e,0x63,0x6f,0x6d,0x0a,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x53,0x75,0x62,0x6a,0x65,0x63,0x74,0x20,0x50,0x75,0x62,0x6c,
           0x69,0x63,0x20,0x4b,0x65,0x79,0x20,0x49,0x6e,0x66,0x6f,0x3a,0x0a,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x50,0x75,0x62,0x6c,0x69,
           0x63,0x20,0x4b,0x65,0x79,0x20,0x41,0x6c,0x67,0x6f,0x72,0x69,0x74,0x68,0x6d,
           0x3a,0x20,0x72,0x73,0x61,0x45,0x6e,0x63,0x72,0x79,0x70,0x74,0x69,0x6f,0x6e,
           0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x52,0x53,
           0x41,0x20,0x50,0x75,0x62,0x6c,0x69,0x63,0x20,0x4b,0x65,0x79,0x3a,0x20,0x28,
           0x31,0x30,0x32,0x34,0x20,0x62,0x69,0x74,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x4d,0x6f,0x64,0x75,
           0x6c,0x75,0x73,0x20,0x28,0x31,0x30,0x32,0x34,0x20,0x62,0x69,0x74,0x29,0x3a,
           0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x3a,0x62,0x39,0x3a,0x65,0x63,0x3a,
           0x62,0x37,0x3a,0x38,0x64,0x3a,0x31,0x33,0x3a,0x30,0x66,0x3a,0x30,0x63,0x3a,
           0x39,0x30,0x3a,0x64,0x64,0x3a,0x32,0x61,0x3a,0x39,0x63,0x3a,0x65,0x65,0x3a,
           0x63,0x38,0x3a,0x61,0x61,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x32,0x3a,
           0x38,0x32,0x3a,0x64,0x38,0x3a,0x33,0x61,0x3a,0x33,0x34,0x3a,0x39,0x31,0x3a,
           0x39,0x36,0x3a,0x31,0x64,0x3a,0x39,0x31,0x3a,0x38,0x30,0x3a,0x39,0x64,0x3a,
           0x63,0x31,0x3a,0x62,0x36,0x3a,0x38,0x30,0x3a,0x34,0x39,0x3a,0x0a,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x62,0x65,0x3a,0x30,0x34,0x3a,0x33,0x33,0x3a,0x63,0x38,0x3a,
           0x65,0x61,0x3a,0x61,0x62,0x3a,0x31,0x65,0x3a,0x63,0x62,0x3a,0x32,0x63,0x3a,
           0x33,0x63,0x3a,0x35,0x31,0x3a,0x34,0x64,0x3a,0x31,0x31,0x3a,0x63,0x66,0x3a,
           0x33,0x34,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x38,0x3a,0x36,0x64,0x3a,
           0x35,0x66,0x3a,0x38,0x36,0x3a,0x66,0x66,0x3a,0x36,0x37,0x3a,0x65,0x65,0x3a,
           0x39,0x32,0x3a,0x35,0x30,0x3a,0x38,0x39,0x3a,0x65,0x38,0x3a,0x36,0x37,0x3a,
           0x62,0x37,0x3a,0x31,0x64,0x3a,0x37,0x33,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x30,0x64,0x3a,0x61,0x38,0x3a,0x63,0x31,0x3a,0x38,0x65,0x3a,0x64,0x37,0x3a,
           0x66,0x31,0x3a,0x63,0x65,0x3a,0x61,0x37,0x3a,0x33,0x31,0x3a,0x31,0x37,0x3a,
           0x30,0x64,0x3a,0x32,0x61,0x3a,0x37,0x31,0x3a,0x37,0x30,0x3a,0x32,0x37,0x3a,
           0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x33,0x3a,0x30,0x39,0x3a,0x38,0x34,0x3a,
           0x32,0x37,0x3a,0x66,0x61,0x3a,0x33,0x33,0x3a,0x65,0x35,0x3a,0x31,0x65,0x3a,
           0x62,0x34,0x3a,0x39,0x35,0x3a,0x33,0x36,0x3a,0x63,0x38,0x3a,0x32,0x38,0x3a,
           0x30,0x38,0x3a,0x35,0x64,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x61,0x3a,
           0x31,0x30,0x3a,0x63,0x37,0x3a,0x34,0x36,0x3a,0x37,0x38,0x3a,0x36,0x39,0x3a,
           0x39,0x37,0x3a,0x38,0x39,0x3a,0x63,0x31,0x3a,0x30,0x31,0x3a,0x31,0x37,0x3a,
           0x32,0x39,0x3a,0x65,0x32,0x3a,0x64,0x62,0x3a,0x36,0x39,0x3a,0x0a,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x61,0x31,0x3a,0x61,0x38,0x3a,0x37,0x30,0x3a,0x39,0x31,0x3a,
           0x31,0x64,0x3a,0x66,0x38,0x3a,0x33,0x34,0x3a,0x36,0x38,0x3a,0x64,0x64,0x3a,
           0x62,0x36,0x3a,0x63,0x64,0x3a,0x66,0x32,0x3a,0x39,0x62,0x3a,0x34,0x64,0x3a,
           0x63,0x64,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x39,0x38,0x3a,0x61,0x62,0x3a,
           0x33,0x39,0x3a,0x35,0x64,0x3a,0x36,0x33,0x3a,0x62,0x62,0x3a,0x63,0x38,0x3a,
           0x33,0x30,0x3a,0x62,0x35,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x45,0x78,0x70,0x6f,0x6e,0x65,0x6e,0x74,
           0x3a,0x20,0x36,0x35,0x35,0x33,0x37,0x20,0x28,0x30,0x78,0x31,0x30,0x30,0x30,
           0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x58,0x35,0x30,0x39,
           0x76,0x33,0x20,0x65,0x78,0x74,0x65,0x6e,0x73,0x69,0x6f,0x6e,0x73,0x3a,0x0a,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x58,0x35,0x30,
           0x39,0x76,0x33,0x20,0x42,0x61,0x73,0x69,0x63,0x20,0x43,0x6f,0x6e,0x73,0x74,
           0x72,0x61,0x69,0x6e,0x74,0x73,0x3a,0x20,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x43,0x41,0x3a,0x46,0x41,
           0x4c,0x53,0x45,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x4e,0x65,0x74,0x73,0x63,0x61,0x70,0x65,0x20,0x43,0x6f,0x6d,0x6d,0x65,
           0x6e,0x74,0x3a,0x20,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x4f,0x70,0x65,0x6e,0x53,0x53,0x4c,0x20,0x47,
           0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x20,0x43,0x65,0x72,0x74,0x69,0x66,
           0x69,0x63,0x61,0x74,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x58,0x35,0x30,0x39,0x76,0x33,0x20,0x53,0x75,0x62,0x6a,0x65,
           0x63,0x74,0x20,0x4b,0x65,0x79,0x20,0x49,0x64,0x65,0x6e,0x74,0x69,0x66,0x69,
           0x65,0x72,0x3a,0x20,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x34,0x3a,0x41,0x33,0x3a,0x44,0x36,0x3a,
           0x39,0x43,0x3a,0x38,0x43,0x3a,0x43,0x36,0x3a,0x36,0x46,0x3a,0x43,0x41,0x3a,
           0x45,0x44,0x3a,0x42,0x38,0x3a,0x44,0x45,0x3a,0x34,0x31,0x3a,0x34,0x30,0x3a,
           0x31,0x31,0x3a,0x42,0x33,0x3a,0x31,0x30,0x3a,0x36,0x36,0x3a,0x37,0x35,0x3a,
           0x30,0x39,0x3a,0x44,0x45,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x58,0x35,0x30,0x39,0x76,0x33,0x20,0x41,0x75,0x74,0x68,0x6f,
           0x72,0x69,0x74,0x79,0x20,0x4b,0x65,0x79,0x20,0x49,0x64,0x65,0x6e,0x74,0x69,
           0x66,0x69,0x65,0x72,0x3a,0x20,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6b,0x65,0x79,0x69,0x64,0x3a,0x44,
           0x39,0x3a,0x44,0x44,0x3a,0x39,0x42,0x3a,0x39,0x34,0x3a,0x36,0x42,0x3a,0x38,
           0x41,0x3a,0x33,0x43,0x3a,0x41,0x45,0x3a,0x32,0x41,0x3a,0x35,0x31,0x3a,0x42,
           0x36,0x3a,0x33,0x44,0x3a,0x37,0x45,0x3a,0x34,0x45,0x3a,0x37,0x43,0x3a,0x39,
           0x42,0x3a,0x39,0x33,0x3a,0x36,0x34,0x3a,0x33,0x30,0x3a,0x45,0x33,0x0a,0x0a,
           0x20,0x20,0x20,0x20,0x53,0x69,0x67,0x6e,0x61,0x74,0x75,0x72,0x65,0x20,0x41,
           0x6c,0x67,0x6f,0x72,0x69,0x74,0x68,0x6d,0x3a,0x20,0x73,0x68,0x61,0x31,0x57,
           0x69,0x74,0x68,0x52,0x53,0x41,0x45,0x6e,0x63,0x72,0x79,0x70,0x74,0x69,0x6f,
           0x6e,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x37,0x65,0x3a,0x30,0x38,
           0x3a,0x61,0x62,0x3a,0x65,0x66,0x3a,0x38,0x37,0x3a,0x34,0x63,0x3a,0x37,0x39,
           0x3a,0x33,0x61,0x3a,0x33,0x31,0x3a,0x39,0x65,0x3a,0x65,0x35,0x3a,0x63,0x37,
           0x3a,0x35,0x35,0x3a,0x35,0x64,0x3a,0x61,0x31,0x3a,0x63,0x32,0x3a,0x30,0x30,
           0x3a,0x36,0x62,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x39,0x38,
           0x3a,0x36,0x35,0x3a,0x31,0x63,0x3a,0x62,0x65,0x3a,0x63,0x30,0x3a,0x39,0x62,
           0x3a,0x36,0x64,0x3a,0x33,0x35,0x3a,0x39,0x63,0x3a,0x35,0x65,0x3a,0x38,0x62,
           0x3a,0x35,0x64,0x3a,0x61,0x33,0x3a,0x66,0x32,0x3a,0x61,0x35,0x3a,0x63,0x61,
           0x3a,0x34,0x62,0x3a,0x64,0x63,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x31,0x61,0x3a,0x64,0x63,0x3a,0x37,0x66,0x3a,0x36,0x31,0x3a,0x36,0x62,
           0x3a,0x31,0x64,0x3a,0x34,0x65,0x3a,0x35,0x33,0x3a,0x34,0x64,0x3a,0x63,0x35,
           0x3a,0x39,0x37,0x3a,0x30,0x64,0x3a,0x30,0x37,0x3a,0x35,0x30,0x3a,0x33,0x37,
           0x3a,0x37,0x33,0x3a,0x34,0x30,0x3a,0x36,0x65,0x3a,0x0a,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x61,0x39,0x3a,0x38,0x62,0x3a,0x34,0x31,0x3a,0x35,0x35,
           0x3a,0x30,0x31,0x3a,0x32,0x37,0x3a,0x35,0x35,0x3a,0x62,0x37,0x3a,0x37,0x66,
           0x3a,0x37,0x30,0x3a,0x30,0x62,0x3a,0x32,0x37,0x3a,0x65,0x34,0x3a,0x31,0x32,
           0x3a,0x38,0x37,0x3a,0x62,0x64,0x3a,0x33,0x35,0x3a,0x33,0x37,0x3a,0x0a,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x39,0x3a,0x66,0x37,0x3a,0x31,0x39,
           0x3a,0x30,0x33,0x3a,0x34,0x32,0x3a,0x61,0x36,0x3a,0x65,0x65,0x3a,0x31,0x62,
           0x3a,0x36,0x62,0x3a,0x64,0x66,0x3a,0x62,0x39,0x3a,0x36,0x37,0x3a,0x66,0x32,
           0x3a,0x63,0x65,0x3a,0x30,0x66,0x3a,0x37,0x61,0x3a,0x33,0x32,0x3a,0x63,0x64,
           0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x36,0x61,0x3a,0x34,0x61,
           0x3a,0x32,0x39,0x3a,0x62,0x65,0x3a,0x63,0x62,0x3a,0x31,0x35,0x3a,0x31,0x34,
           0x3a,0x37,0x66,0x3a,0x38,0x33,0x3a,0x32,0x66,0x3a,0x36,0x37,0x3a,0x64,0x65,
           0x3a,0x30,0x63,0x3a,0x39,0x39,0x3a,0x30,0x39,0x3a,0x61,0x61,0x3a,0x34,0x61,
           0x3a,0x62,0x36,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x61,
           0x3a,0x63,0x63,0x3a,0x66,0x63,0x3a,0x31,0x36,0x3a,0x37,0x66,0x3a,0x30,0x37,
           0x3a,0x39,0x63,0x3a,0x38,0x63,0x3a,0x38,0x66,0x3a,0x33,0x34,0x3a,0x63,0x64,
           0x3a,0x34,0x30,0x3a,0x63,0x30,0x3a,0x32,0x62,0x3a,0x30,0x65,0x3a,0x39,0x62,
           0x3a,0x36,0x63,0x3a,0x62,0x33,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x61,0x63,0x3a,0x35,0x38,0x3a,0x61,0x38,0x3a,0x35,0x36,0x3a,0x39,0x36,
           0x3a,0x32,0x31,0x3a,0x38,0x63,0x3a,0x65,0x36,0x3a,0x66,0x63,0x3a,0x32,0x62,
           0x3a,0x64,0x63,0x3a,0x34,0x36,0x3a,0x65,0x62,0x3a,0x64,0x66,0x3a,0x38,0x38,
           0x3a,0x39,0x32,0x3a,0x61,0x35,0x3a,0x30,0x34,0x3a,0x0a,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x65,0x39,0x3a,0x39,0x36,0x3a,0x64,0x38,0x3a,0x38,0x38,
           0x3a,0x64,0x65,0x3a,0x34,0x37,0x3a,0x36,0x64,0x3a,0x36,0x30,0x3a,0x34,0x64,
           0x3a,0x33,0x30,0x3a,0x61,0x61,0x3a,0x61,0x62,0x3a,0x31,0x62,0x3a,0x65,0x61,
           0x3a,0x39,0x65,0x3a,0x32,0x66,0x3a,0x37,0x31,0x3a,0x35,0x61,0x3a,0x0a,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x37,0x3a,0x30,0x63,0x3a,0x30,0x35,
           0x3a,0x39,0x30,0x3a,0x32,0x31,0x3a,0x39,0x66,0x3a,0x34,0x39,0x3a,0x62,0x39,
           0x3a,0x66,0x32,0x3a,0x37,0x32,0x3a,0x38,0x65,0x3a,0x38,0x39,0x3a,0x39,0x36,
           0x3a,0x66,0x61,0x3a,0x62,0x61,0x3a,0x63,0x61,0x3a,0x39,0x32,0x3a,0x62,0x61,
           0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x35,0x35,0x3a,0x34,0x35,
           0x3a,0x61,0x34,0x3a,0x39,0x38,0x3a,0x62,0x37,0x3a,0x62,0x61,0x3a,0x32,0x64,
           0x3a,0x38,0x36,0x3a,0x35,0x34,0x3a,0x31,0x36,0x3a,0x39,0x34,0x3a,0x37,0x61,
           0x3a,0x63,0x66,0x3a,0x34,0x31,0x3a,0x39,0x61,0x3a,0x31,0x39,0x3a,0x30,0x35,
           0x3a,0x30,0x65,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x32,
           0x3a,0x39,0x65,0x3a,0x39,0x63,0x3a,0x65,0x35,0x3a,0x33,0x64,0x3a,0x36,0x35,
           0x3a,0x34,0x34,0x3a,0x65,0x39,0x3a,0x33,0x63,0x3a,0x66,0x63,0x3a,0x36,0x32,
           0x3a,0x34,0x63,0x3a,0x35,0x61,0x3a,0x30,0x35,0x3a,0x62,0x34,0x3a,0x64,0x39,
           0x3a,0x31,0x38,0x3a,0x38,0x37,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
           0x20,0x65,0x35,0x3a,0x39,0x34,0x3a,0x36,0x35,0x3a,0x32,0x33,0x3a,0x65,0x62,
           0x3a,0x34,0x65,0x3a,0x64,0x64,0x3a,0x66,0x37,0x3a,0x65,0x32,0x3a,0x39,0x37,
           0x3a,0x38,0x34,0x3a,0x36,0x39,0x3a,0x31,0x35,0x3a,0x62,0x66,0x3a,0x39,0x31,
           0x3a,0x39,0x63,0x3a,0x66,0x39,0x3a,0x34,0x66,0x3a,0x0a,0x20,0x20,0x20,0x20,
           0x20,0x20,0x20,0x20,0x63,0x34,0x3a,0x36,0x31,0x3a,0x65,0x62,0x3a,0x61,0x30,
           0x3a,0x30,0x31,0x3a,0x66,0x38,0x3a,0x34,0x65,0x3a,0x65,0x38,0x3a,0x37,0x36,
           0x3a,0x31,0x36,0x3a,0x61,0x61,0x3a,0x37,0x62,0x3a,0x31,0x37,0x3a,0x39,0x36,
           0x3a,0x63,0x32,0x3a,0x66,0x35,0x3a,0x32,0x61,0x3a,0x37,0x39,0x3a,0x0a,0x20,
           0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x62,0x3a,0x64,0x33,0x3a,0x30,0x31,
           0x3a,0x33,0x64,0x0a,0x2d,0x2d,0x2d,0x2d,0x2d,0x42,0x45,0x47,0x49,0x4e,0x20,
           0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x2d,0x2d,0x2d,0x2d,
           0x2d,0x0a,0x4d,0x49,0x49,0x44,0x6d,0x7a,0x43,0x43,0x41,0x6f,0x4f,0x67,0x41,
           0x77,0x49,0x42,0x41,0x67,0x49,0x43,0x41,0x52,0x34,0x77,0x44,0x51,0x59,0x4a,
           0x4b,0x6f,0x5a,0x49,0x68,0x76,0x63,0x4e,0x41,0x51,0x45,0x46,0x42,0x51,0x41,
           0x77,0x67,0x5a,0x4d,0x78,0x43,0x7a,0x41,0x4a,0x42,0x67,0x4e,0x56,0x42,0x41,
           0x59,0x54,0x41,0x6e,0x56,0x7a,0x0a,0x4d,0x51,0x73,0x77,0x43,0x51,0x59,0x44,
           0x56,0x51,0x51,0x49,0x45,0x77,0x4a,0x33,0x59,0x54,0x45,0x51,0x4d,0x41,0x34,
           0x47,0x41,0x31,0x55,0x45,0x42,0x78,0x4d,0x48,0x55,0x6d,0x56,0x6b,0x62,0x57,
           0x39,0x75,0x5a,0x44,0x45,0x53,0x4d,0x42,0x41,0x47,0x41,0x31,0x55,0x45,0x43,
           0x68,0x4d,0x4a,0x54,0x57,0x6c,0x6a,0x63,0x6d,0x39,0x7a,0x0a,0x62,0x32,0x5a,
           0x30,0x4d,0x51,0x30,0x77,0x43,0x77,0x59,0x44,0x56,0x51,0x51,0x4c,0x45,0x77,
           0x52,0x54,0x55,0x45,0x39,0x55,0x4d,0x52,0x30,0x77,0x47,0x77,0x59,0x44,0x56,
           0x51,0x51,0x44,0x45,0x78,0x52,0x45,0x5a,0x58,0x5a,0x70,0x59,0x32,0x55,0x75,
           0x54,0x57,0x6c,0x6a,0x63,0x6d,0x39,0x7a,0x62,0x32,0x5a,0x30,0x4c,0x6b,0x4e,
           0x76,0x0a,0x62,0x54,0x45,0x6a,0x4d,0x43,0x45,0x47,0x43,0x53,0x71,0x47,0x53,
           0x49,0x62,0x33,0x44,0x51,0x45,0x4a,0x41,0x52,0x59,0x55,0x59,0x57,0x78,0x6b,
           0x5a,0x57,0x35,0x73,0x51,0x47,0x31,0x70,0x59,0x33,0x4a,0x76,0x63,0x32,0x39,
           0x6d,0x64,0x43,0x35,0x6a,0x62,0x32,0x30,0x77,0x48,0x68,0x63,0x4e,0x4d,0x44,
           0x67,0x77,0x4d,0x7a,0x49,0x78,0x0a,0x4d,0x6a,0x49,0x7a,0x4d,0x6a,0x41,0x34,
           0x57,0x68,0x63,0x4e,0x4d,0x44,0x6b,0x77,0x4d,0x7a,0x49,0x78,0x4d,0x6a,0x49,
           0x7a,0x4d,0x6a,0x41,0x34,0x57,0x6a,0x43,0x42,0x6b,0x7a,0x45,0x4c,0x4d,0x41,
           0x6b,0x47,0x41,0x31,0x55,0x45,0x42,0x68,0x4d,0x43,0x64,0x58,0x4d,0x78,0x43,
           0x7a,0x41,0x4a,0x42,0x67,0x4e,0x56,0x42,0x41,0x67,0x54,0x0a,0x41,0x6e,0x64,
           0x68,0x4d,0x52,0x41,0x77,0x44,0x67,0x59,0x44,0x56,0x51,0x51,0x48,0x45,0x77,
           0x64,0x79,0x5a,0x57,0x52,0x74,0x62,0x32,0x35,0x6b,0x4d,0x52,0x49,0x77,0x45,
           0x41,0x59,0x44,0x56,0x51,0x51,0x4b,0x45,0x77,0x6c,0x74,0x61,0x57,0x4e,0x79,
           0x62,0x33,0x4e,0x76,0x5a,0x6e,0x51,0x78,0x44,0x54,0x41,0x4c,0x42,0x67,0x4e,
           0x56,0x0a,0x42,0x41,0x73,0x54,0x42,0x46,0x4e,0x51,0x54,0x31,0x51,0x78,0x48,
           0x54,0x41,0x62,0x42,0x67,0x4e,0x56,0x42,0x41,0x4d,0x54,0x46,0x45,0x52,0x6c,
           0x64,0x6d,0x6c,0x6a,0x5a,0x53,0x35,0x4e,0x61,0x57,0x4e,0x79,0x62,0x33,0x4e,
           0x76,0x5a,0x6e,0x51,0x75,0x51,0x32,0x39,0x74,0x4d,0x53,0x4d,0x77,0x49,0x51,
           0x59,0x4a,0x4b,0x6f,0x5a,0x49,0x0a,0x68,0x76,0x63,0x4e,0x41,0x51,0x6b,0x42,
           0x46,0x68,0x52,0x68,0x62,0x47,0x52,0x6c,0x62,0x6d,0x78,0x41,0x62,0x57,0x6c,
           0x6a,0x63,0x6d,0x39,0x7a,0x62,0x32,0x5a,0x30,0x4c,0x6d,0x4e,0x76,0x62,0x54,
           0x43,0x42,0x6e,0x7a,0x41,0x4e,0x42,0x67,0x6b,0x71,0x68,0x6b,0x69,0x47,0x39,
           0x77,0x30,0x42,0x41,0x51,0x45,0x46,0x41,0x41,0x4f,0x42,0x0a,0x6a,0x51,0x41,
           0x77,0x67,0x59,0x6b,0x43,0x67,0x59,0x45,0x41,0x75,0x65,0x79,0x33,0x6a,0x52,
           0x4d,0x50,0x44,0x4a,0x44,0x64,0x4b,0x70,0x7a,0x75,0x79,0x4b,0x71,0x79,0x67,
           0x74,0x67,0x36,0x4e,0x4a,0x47,0x57,0x48,0x5a,0x47,0x41,0x6e,0x63,0x47,0x32,
           0x67,0x45,0x6d,0x2b,0x42,0x44,0x50,0x49,0x36,0x71,0x73,0x65,0x79,0x79,0x77,
           0x38,0x0a,0x55,0x55,0x30,0x52,0x7a,0x7a,0x51,0x6f,0x62,0x56,0x2b,0x47,0x2f,
           0x32,0x66,0x75,0x6b,0x6c,0x43,0x4a,0x36,0x47,0x65,0x33,0x48,0x58,0x4d,0x4e,
           0x71,0x4d,0x47,0x4f,0x31,0x2f,0x48,0x4f,0x70,0x7a,0x45,0x58,0x44,0x53,0x70,
           0x78,0x63,0x43,0x63,0x54,0x43,0x59,0x51,0x6e,0x2b,0x6a,0x50,0x6c,0x48,0x72,
           0x53,0x56,0x4e,0x73,0x67,0x6f,0x0a,0x43,0x46,0x32,0x36,0x45,0x4d,0x64,0x47,
           0x65,0x47,0x6d,0x58,0x69,0x63,0x45,0x42,0x46,0x79,0x6e,0x69,0x32,0x32,0x6d,
           0x68,0x71,0x48,0x43,0x52,0x48,0x66,0x67,0x30,0x61,0x4e,0x32,0x32,0x7a,0x66,
           0x4b,0x62,0x54,0x63,0x32,0x59,0x71,0x7a,0x6c,0x64,0x59,0x37,0x76,0x49,0x4d,
           0x4c,0x55,0x43,0x41,0x77,0x45,0x41,0x41,0x61,0x4e,0x37,0x0a,0x4d,0x48,0x6b,
           0x77,0x43,0x51,0x59,0x44,0x56,0x52,0x30,0x54,0x42,0x41,0x49,0x77,0x41,0x44,
           0x41,0x73,0x42,0x67,0x6c,0x67,0x68,0x6b,0x67,0x42,0x68,0x76,0x68,0x43,0x41,
           0x51,0x30,0x45,0x48,0x78,0x59,0x64,0x54,0x33,0x42,0x6c,0x62,0x6c,0x4e,0x54,
           0x54,0x43,0x42,0x48,0x5a,0x57,0x35,0x6c,0x63,0x6d,0x46,0x30,0x5a,0x57,0x51,
           0x67,0x0a,0x51,0x32,0x56,0x79,0x64,0x47,0x6c,0x6d,0x61,0x57,0x4e,0x68,0x64,
           0x47,0x55,0x77,0x48,0x51,0x59,0x44,0x56,0x52,0x30,0x4f,0x42,0x42,0x59,0x45,
           0x46,0x43,0x53,0x6a,0x31,0x70,0x79,0x4d,0x78,0x6d,0x2f,0x4b,0x37,0x62,0x6a,
           0x65,0x51,0x55,0x41,0x52,0x73,0x78,0x42,0x6d,0x64,0x51,0x6e,0x65,0x4d,0x42,
           0x38,0x47,0x41,0x31,0x55,0x64,0x0a,0x49,0x77,0x51,0x59,0x4d,0x42,0x61,0x41,
           0x46,0x4e,0x6e,0x64,0x6d,0x35,0x52,0x72,0x69,0x6a,0x79,0x75,0x4b,0x6c,0x47,
           0x32,0x50,0x58,0x35,0x4f,0x66,0x4a,0x75,0x54,0x5a,0x44,0x44,0x6a,0x4d,0x41,
           0x30,0x47,0x43,0x53,0x71,0x47,0x53,0x49,0x62,0x33,0x44,0x51,0x45,0x42,0x42,
           0x51,0x55,0x41,0x41,0x34,0x49,0x42,0x41,0x51,0x42,0x2b,0x0a,0x43,0x4b,0x76,
           0x76,0x68,0x30,0x78,0x35,0x4f,0x6a,0x47,0x65,0x35,0x63,0x64,0x56,0x58,0x61,
           0x48,0x43,0x41,0x47,0x75,0x59,0x5a,0x52,0x79,0x2b,0x77,0x4a,0x74,0x74,0x4e,
           0x5a,0x78,0x65,0x69,0x31,0x32,0x6a,0x38,0x71,0x58,0x4b,0x53,0x39,0x77,0x61,
           0x33,0x48,0x39,0x68,0x61,0x78,0x31,0x4f,0x55,0x30,0x33,0x46,0x6c,0x77,0x30,
           0x48,0x0a,0x55,0x44,0x64,0x7a,0x51,0x47,0x36,0x70,0x69,0x30,0x46,0x56,0x41,
           0x53,0x64,0x56,0x74,0x33,0x39,0x77,0x43,0x79,0x66,0x6b,0x45,0x6f,0x65,0x39,
           0x4e,0x54,0x63,0x4a,0x39,0x78,0x6b,0x44,0x51,0x71,0x62,0x75,0x47,0x32,0x76,
           0x66,0x75,0x57,0x66,0x79,0x7a,0x67,0x39,0x36,0x4d,0x73,0x31,0x71,0x53,0x69,
           0x6d,0x2b,0x79,0x78,0x55,0x55,0x0a,0x66,0x34,0x4d,0x76,0x5a,0x39,0x34,0x4d,
           0x6d,0x51,0x6d,0x71,0x53,0x72,0x62,0x4b,0x7a,0x50,0x77,0x57,0x66,0x77,0x65,
           0x63,0x6a,0x49,0x38,0x30,0x7a,0x55,0x44,0x41,0x4b,0x77,0x36,0x62,0x62,0x4c,
           0x4f,0x73,0x57,0x4b,0x68,0x57,0x6c,0x69,0x47,0x4d,0x35,0x76,0x77,0x72,0x33,
           0x45,0x62,0x72,0x33,0x34,0x69,0x53,0x70,0x51,0x54,0x70,0x0a,0x6c,0x74,0x69,
           0x49,0x33,0x6b,0x64,0x74,0x59,0x45,0x30,0x77,0x71,0x71,0x73,0x62,0x36,0x70,
           0x34,0x76,0x63,0x56,0x6f,0x6e,0x44,0x41,0x57,0x51,0x49,0x5a,0x39,0x4a,0x75,
           0x66,0x4a,0x79,0x6a,0x6f,0x6d,0x57,0x2b,0x72,0x72,0x4b,0x6b,0x72,0x70,0x56,
           0x52,0x61,0x53,0x59,0x74,0x37,0x6f,0x74,0x68,0x6c,0x51,0x57,0x6c,0x48,0x72,
           0x50,0x0a,0x51,0x5a,0x6f,0x5a,0x42,0x51,0x34,0x69,0x6e,0x70,0x7a,0x6c,0x50,
           0x57,0x56,0x45,0x36,0x54,0x7a,0x38,0x59,0x6b,0x78,0x61,0x42,0x62,0x54,0x5a,
           0x47,0x49,0x66,0x6c,0x6c,0x47,0x55,0x6a,0x36,0x30,0x37,0x64,0x39,0x2b,0x4b,
           0x58,0x68,0x47,0x6b,0x56,0x76,0x35,0x47,0x63,0x2b,0x55,0x2f,0x45,0x59,0x65,
           0x75,0x67,0x41,0x66,0x68,0x4f,0x0a,0x36,0x48,0x59,0x57,0x71,0x6e,0x73,0x58,
           0x6c,0x73,0x4c,0x31,0x4b,0x6e,0x6e,0x37,0x30,0x77,0x45,0x39,0x0a,0x2d,0x2d,
           0x2d,0x2d,0x2d,0x45,0x4e,0x44,0x20,0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,
           0x41,0x54,0x45,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a

           };

        #endregion

        public static void Main()
        {
            // Demo for MFToolkit.Cryptography
            //byte[] buf = Encoding.UTF8.GetBytes("Hello World");
            //using (MemoryStream ms = new MemoryStream(buf))
            //{
            //    Debug.Print(MFToolkit.Cryptography.SHA1.Compute(ms, 0, buf.Length));
            //    ms.Seek(0, SeekOrigin.Begin);
            //    Debug.Print(MFToolkit.Cryptography.SHA256.Compute(ms, 0, buf.Length));
            //}

            // Demo for NtpClient
            //Microsoft.SPOT.Time.TimeService.SetTimeZoneOffset(60);
            //Microsoft.SPOT.Time.TimeService.SetUtcTime(NtpClient.GetNetworkTime().Ticks);
            //Microsoft.SPOT.Hardware.Utility.SetLocalTime(NtpClient.GetNetworkTime());

            // Demo for HttpServer
            foreach (NetworkInterface net in NetworkInterface.GetAllNetworkInterfaces())
                Debug.Print(net.IPAddress.ToString());

            // change the port 80 to 81 if running inside the emulator
            using (HttpServer http = new HttpServer(81, new MyHttpHandler()))
            {
                //http.IsSecure = true;
                //http.Certificate = new X509Certificate(caCert);
                http.Start();
                 
                while (!stopThread)
                {
                    Thread.Sleep(1000);
                }
            }
        }

        static void ResetResourceManager()
        {
            FieldInfo fieldInfo = typeof(Resources).GetField("manager",
                                                    BindingFlags.NonPublic | BindingFlags.Static);
            fieldInfo.SetValue(null, null);
        }

        static void SetCulture(string cultureName)
        {
            ResourceUtility.SetCurrentUICulture(new CultureInfo(cultureName));
            ResetResourceManager();
            // render screen with new culture
        } 
    }

    public class MyHttpHandler : IHttpHandler
    {
        const string htmlhead = "<html><head><title>Demo</title></head><body>";
        const string htmlfoot = "</body></html>";

        #region IHttpHandler Members

        public void ProcessRequest(HttpContext context)
        {
            context.Response.RemoveHeader("Connection");

            //if (!String.IsNullOrEmpty(_rootFolder) && context.Request.Path != null)
            //{
            //    string filename = Path.Combine(_rootFolder, context.Request.Path.Replace("/", "\\").Substring(1));
            //    if (filename.IndexOf("..") < 0 && filename.ToLower().StartsWith(_rootFolder.ToLower()))   // ensure that the files are below _rootFolder
            //    {
            //        if (File.Exists(filename))
            //        {
            //            if (Path.GetExtension(filename) == ".htm")
            //                context.Response.ContentType = "text/html; charset=UTF-8";
            //            else if (Path.GetExtension(filename) == ".jpg")
            //                context.Response.ContentType = "image/jpeg";

            //            context.Response.Write(File.ReadAllBytes(filename));
            //            return;
            //        }
            //    }
            //}

            switch (context.Request.Path)
            {
                case "/imbot":
                    context.Response.ContentType = "text/html; charset=UTF-8";

                    switch (context.Request.Form["step"])
                    {
                        case "2":
                            context.Response.WriteLine("Hi " + context.Request["value1"] + ", where do you live?");
                            break;

                        case "3":
                            context.Response.WriteLine("Well, welcome to this hello world bot, " + context.Request["value1"] + " from " + context.Request["value2"] + ".");
                            context.Response.WriteLine("<br/>");
                            context.Response.WriteLine("Visit my blog at http://netmicroframework.blogspot.com/");
                            context.Response.WriteLine("<reset>");
                            break;

                        case "1":
                            context.Response.WriteLine("Hi, what's your name?");
                            break;

                        default:
                            context.Response.WriteLine("<goto=1>");
                            break;
                    }

                    break;

                case "/test":
                    context.Response.Redirect("/test.aspx");
                    break;

                case "/xbee":
                    context.Response.ContentType = "text/html; charset=UTF-8";

                    using (XBee xbee = new XBee("COM2", 9600, ApiType.Enabled))
                    {
                        xbee.Open();
                        AtCommandResponse cr = (AtCommandResponse)xbee.Execute(new NodeIdentifierCommand());
                        context.Response.WriteLine(NodeIdentifier.Parse(cr).ToString());
                    }

                    break;

                case "/test2.aspx":
                    context.Response.ContentType = "text/html; charset=UTF-8";
                    context.Response.Write("<html><head><title></title></head><body>" + new string(Encoding.UTF8.GetChars(context.Request.Body)) + "</body></html>");
                    break;

                case "/cookie":
                    context.Response.ContentType = "text/html; charset=UTF-8";
                    context.Response.Write("<html><head><title></title></head><body>");

                    if (context.Request.Cookies.Count > 0)
                    {
                        foreach (HttpCookie c in context.Request.Cookies)
                            context.Response.WriteLine("Cookie " + c.Name + " = " + c.Value + "<br/>");
                    }

                    HttpCookie cookie = new HttpCookie("test", DateTime.Now.ToString());
                    cookie.Expires = DateTime.Now.AddDays(2);
                    context.Response.SetCookie(cookie);
                    context.Response.WriteLine("</body></html>");

                    break;

                case "/test.aspx":
                    context.Response.ContentType = "text/html; charset=UTF-8";
                    context.Response.Write("<html><head><title></title><script type=\"text/javascript\" src=\"/scripts/test.js\"></script></head><body><form action=\"/test2.aspx\" method=\"post\"><input type=\"text\" id=\"txtbox1\" name=\"txtbox1\"/><input type=\"submit\" value=\"Post\"/></form></body></html>");
                    break;

                case "/scripts/test.js":
                    context.Response.ContentType = "text/javascript";
                    context.Response.Write(@"
var c = 0;
var d = new Date();
function test() {
    var x = window.ActiveXObject ? new ActiveXObject(""Microsoft.XMLHTTP"") : new XMLHttpRequest();
    x.onreadystatechange = function() {
        if(x.readyState == 4) {
            document.getElementById('txtbox1').value = x.responseText;
            if(++c <= 5)
                setTimeout(test, 1);
        }
    }
    x.open(""POST"", ""/test.ajax?x="" + c, true);
    x.send("""" + c);
}
setTimeout(test, 1);
");
                    break;

                case "/test.ajax":

                    //if (context.Request.Connection.ToLower() == "keep-alive")
                    //{
                    //    context.Response.AddHeader("Connection", "Keep-Alive");
                    //    context.Response.AddHeader("Keep-Alive", "timeout=15, max=100");
                    //}

                    if (context.Request.Body != null && context.Request.Body.Length > 0)
                        context.Response.Write("ajax = " + new string(Encoding.UTF8.GetChars(context.Request.Body)));
                    else
                        context.Response.Write("ajax = could not read request");

                    break;

                default:
                    context.Response.ContentType = "text/html; charset=UTF-8";
                    context.Response.Write("<html><head><title>Control My World - How to switch lights on and heating off?</title></head><body>");


                    context.Response.Write("<h1>Welcome to my .NET Micro Framework web server</h1><p>This demo server is running on a Tahoe-II board using XBee modules to communicate with XBee sensors from Digi.</p><p>On my device the current date is " + DateTime.Now + "</b><p><b>RawUrl: " + context.Request.RawUrl + "</b><br/>" + context.Request.Headers["User-Agent"] + "</p>");

                    if (context.Request.Params != null && context.Request.Params.Count > 0)
                    {
                        context.Response.Write("<h3>Params</h3>");
                        context.Response.Write("<p style=\"color:blue\">");

                        foreach (string key in context.Request.Params.AllKeys)
                            context.Response.Write(key + " = " + context.Request.Params[key] + "<br/>");

                        context.Response.Write("</p>");
                    }

                    if (context.Request.Form != null && context.Request.Form.Count > 0)
                    {
                        context.Response.Write("<h3>Form</h3>");
                        context.Response.Write("<p style=\"color:brown\">");

                        foreach (string key in context.Request.Form.AllKeys)
                            context.Response.Write(key + " = " + context.Request.Form[key] + "<br/>");

                        context.Response.Write("</p>");
                    }

                    if (context.Request.MimeContent != null)
                    {
                        context.Response.Write("<h3>MIME Content</h3>");

                        foreach (string key in context.Request.MimeContent.AllKeys)
                        {
                            MimeContent mime = context.Request.MimeContent[key];

                            context.Response.Write("<p style=\"color:blue\">");
                            context.Response.Write(key + " =&gt; " + (mime.Content != null ? mime.Content.Length.ToString() : "0") + " bytes<br/>");

                            foreach (string mkey in context.Request.MimeContent[key].Headers.Keys)
                                context.Response.Write("<i>" + mkey + " : " + context.Request.MimeContent[key].Headers[mkey] + "</i><br/>");

                            context.Response.Write("</p>");

                            if (mime.Headers["Content-Type"] == "text/plain" && mime.Content != null && mime.Content.Length > 0)
                                context.Response.Write("<pre>" + new string(Encoding.UTF8.GetChars(mime.Content)) + "</pre>");
                        }
                    }

                    if (context.Request.Headers != null && context.Request.Headers.Count > 0)
                    {
                        context.Response.Write("<h3>HTTP Header</h3>");
                        context.Response.Write("<p style=\"color:green\">");

                        foreach (string key in context.Request.Headers.AllKeys)
                            context.Response.Write(key + " = " + context.Request.Headers[key] + "<br/>");

                        context.Response.Write("</p>");
                    }

                    if (context.Request.Body != null)
                    {
                        context.Response.Write("<h3>Received Bytes:</h3>");
                        context.Response.Write("<p>" + context.Request.Body.Length + " bytes</p>");
                        context.Response.Write("<hr size=1/>");
                    }

                    context.Response.Write(@"<p><a href=""index.htm"">Demo HTML and JPEG (files on SD card)</a><br/>
<a href=""test.txt"">Demo Plain Text (file on SD card)</a><br/>
<a href=""test"">Redirect Test</a> calls /test and gets redirected to /test.aspx<br/>
<a href=""test.aspx"">AJAX Test</a> requests 5 times a value from webserver<br/>
<a href=""cookie"">Cookie Test</a> sets and displays a cookie<br/></p>
<hr size=1/>
<p>Any feedback welcome: <a href=""http://weblogs.asp.net/mschwarz/contact.aspx"">contact</a>
<a href=""http://michael-schwarz.blogspot.com/"">My Blog</a> <a href=""http://weblogs.asp.net/mschwarz/"">My Blog (en)</a></p>
</body></html>");
                    break;
            } 
        }

        #endregion
    }
}
